<div class="tabs">
    <ul>
        <li><a href="#tabs-1" rel="<?php echo Application_Model_Items::S_HOME ?>">Główna</a></li>
        <li><a href="#tabs-1" rel="<?php echo Application_Model_Items::S_NEW ?>">Oczekujące</a></li>
    </ul>
    <div id="tabs-1">

        <?php echo $this->render('grid_header.phtml') ?>
        <table class="data-grid">
            <thead>
                <tr>
                    <th style="width: 28px" class="br">
            <div class="sort-column">
                <span class="sort-label fl">ID</span>
                <div class="sort fr">
                    <span class="asc fieldNameitemId" ></span>
                    <span class="desc fieldNameitemId"></span>
                </div>
                <div class="cls"></div>
            </div>
            </th>
            <th style="width: 40px" class="br">
            <div class="sort-column">
                <span class="sort-label fl">Fb Like</span>
                <div class="sort fr">
                    <span class="asc fieldNamefb" ></span>
                    <span class="desc fieldNamefb"></span>
                </div>
                <div class="cls"></div>
            </div>
            </th>
            <th class="br" style="width: 125px">
            <div class="sort-column" >
                <span class="sort-label fl">Tytuł</span>
                <div class="sort fr">
                    <span class="asc fieldNametitle"></span>
                    <span class="desc fieldNametitle"></span>
                </div>
                <div class="cls"></div>
            </div>
            </th>
            <th class="br">
            <div class="sort-column">
                <span class="sort-label fl">Użyt.</span>
                <div class="sort fr">
                    <span class="asc fieldNamelogin"></span>
                    <span class="desc fieldNamelogin"></span>
                </div>
                <div class="cls"></div>
            </div>
            </th>
            <th class="br">
            <div class="sort-column">
                <span class="sort-label fl">Dodano</span>
                <div class="sort fr">
                    <span class="asc"></span>
                    <span class="desc"></span>
                </div>
                <div class="cls"></div>
            </div>
            </th>
            <th class="br" style="width: 64px">
            <div class="sort-column">
                <span class="sort-label fl">Kom.</span>
                <div class="sort fr">
                    <span class="asc"></span>
                    <span class="desc"></span>
                </div>
                <div class="cls"></div>
            </div>
            </th>
            <th class="br">Weryfikacja

            </th>
            <th class="br">Ukrywanie</th>
            <th class="br">Przenieś</th>
            <th>
                <span>Akcja</span><br>
                <span class="hidden-data">{"filterUrl":"/admin/index/index"}</span>
                <a class="ajaxFilter" href="javascript:void(0);">Filtruj</a>
                <a class="ajaxFilterClear" href="javascript:void(0);">Wyczyść</a>
            </th>
            </tr>
            <tr>
                <td class="br">
                    <div class="ui-filter">
                        <input type="text" name="filteritemId" class="filterField" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['itemId'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <input type="text" name="filterfb" class="filterField" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['fb'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <input type="text" name="filtertitle" class="filterField" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['title'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <input type="text" name="filterlogin" class="filterField" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['login'] ?>"}</span>
                    </div>
                </td>

                <td class="br">
                    <div class="ui-filter">
                        <input type="text" name="filtercreatedod" class="filterField datepicker" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['createdod'] ?>"}</span>
                    </div>
                    <div class="ui-filter">
                        <input type="text" name="filtercreateddo" class="filterField datepicker" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['createddo'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <input type="text" name="filtercomments" class="filterField" />
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['comments'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <select name="filterverified" class="filterField">
                            <option label="-----" value="-1" >-----</option>
                            <option label="<?php echo Application_Model_Items::$V_NAMES[Application_Model_Items::V_NO] ?>" value="<?php echo Application_Model_Items::V_NO ?>" ><?php echo Application_Model_Items::$V_NAMES[Application_Model_Items::V_NO] ?></option>
                            <option label="<?php echo Application_Model_Items::$V_NAMES[Application_Model_Items::V_YES] ?>" value="<?php echo Application_Model_Items::V_YES ?>" ><?php echo Application_Model_Items::$V_NAMES[Application_Model_Items::V_YES] ?></option>
                        </select>
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['verified'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <select name="filteractive" class="filterField">
                            <option label="-----" value="-1" >-----</option>
                            <option label="<?php echo Application_Model_Items::$A_NAMES[Application_Model_Items::A_NO] ?>" value="<?php echo Application_Model_Items::A_NO ?>" ><?php echo Application_Model_Items::$A_NAMES[Application_Model_Items::A_NO] ?></option>
                            <option label="<?php echo Application_Model_Items::$A_NAMES[Application_Model_Items::A_YES] ?>" value="<?php echo Application_Model_Items::A_YES ?>" ><?php echo Application_Model_Items::$A_NAMES[Application_Model_Items::A_YES] ?></option>
                        </select>
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['active'] ?>"}</span>
                    </div>
                </td>
                <td class="br">
                    <div class="ui-filter">
                        <select name="filterstatus" class="filterField">
                            <option label="-----" value="-1" >-----</option>
                            <option label="<?php echo Application_Model_Items::$STATUS_NAMES[Application_Model_Items::S_HOME] ?>" value="<?php echo Application_Model_Items::S_HOME ?>" ><?php echo Application_Model_Items::$STATUS_NAMES[Application_Model_Items::S_HOME] ?></option>
                            <option label="<?php echo Application_Model_Items::$STATUS_NAMES[Application_Model_Items::S_NEW] ?>" value="<?php echo Application_Model_Items::S_NEW ?>" ><?php echo Application_Model_Items::$STATUS_NAMES[Application_Model_Items::S_NEW] ?></option>
                        </select>
                        <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['status'] ?>"}</span>
                    </div>
                </td>
                <td>

                </td>
            </tr>

            </thead>
            <tbody>
                <?php if (count($this->paginator)): ?>
                    <?php foreach ($this->paginator as $idx => $item): ?>
                        <tr class="item-<?php echo $idx ?>">
                            <td class="br"><?php echo $item['itemId'] ?></td>
                            <td class="br"><?php echo $item['fblike'] ?></td>
                            <td class="br" >
                                <div class="text">
                                <a class="edit-link default" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'itemedit', 'id' => $item['itemId']), null, true) ?>">
                                    <?php echo $this->strlen($item['title'], 60) ?>
                                </a>
                                </div>
                            </td>
                            <td class="br">
                                <a class="default" href="/admin/index/users/filterid/<?php echo $item['userId'] ?>">
                                    <?php echo $item['login'] ?>
                                </a>
                            </td>
                            <td class="br"><?php echo date("Y-m-d", strtotime($item['created'])).'<br/><small>'.date("H:i:s", strtotime($item['created'])).'</small' ?></td>
                            <td class="br">
                                <span><?php echo $item['comments'] ?></span>
                                <a class="default" href="/admin/index/comments/filteritem/<?php echo $item['itemId'] ?>">Pokaż</a>
                            </td>
                            <td class="br">
                                <a rel="<?php echo $item['itemId'] ?>v" class="ajax-post default" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['itemId'], 'table' => 'items'), null, true) ?>"><?php echo $item['verified'] == 1 ? '' : 'Zweryfikuj' ?></a>
                                <div id="ajx-pdata-<?php echo $item['itemId'] ?>v" class="ajax-post-data"><?php echo Zend_Json::encode(array('verified' => $item['verified'] == 1 ? 0 : 1)) ?></div>
                            </td>
                            <td class="br">
                                <a  rel="<?php echo $item['itemId'] ?>a" class="ajax-post<?php echo $item['active'] == 0 ? ' red' : ' default' ?>" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['itemId'], 'table' => 'items'), null, true) ?>"><?php echo $item['active'] == 0 ? 'Aktywuj' : 'Dezaktywuj' ?></a>
                                <div id="ajx-pdata-<?php echo $item['itemId'] ?>a" class="ajax-post-data"><?php echo Zend_Json::encode(array('active' => $item['active'] == 0 ? 1 : 0)) ?></div>
                            </td>
                            <td class="br">
                                <a  rel="<?php echo $item['itemId'] ?>" class="ajax-post" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['itemId'], 'table' => 'items'), null, true) ?>">Przenieś do '<?php echo Application_Model_Items::$STATUS_NAMES[$item['status'] == Application_Model_Items::S_HOME ? Application_Model_Items::S_NEW : Application_Model_Items::S_HOME] ?>'</a>
                            </td>
                            <td >
                                <a rel="<?php echo $item['itemId'] ?>d" class="ajax-post" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['itemId'], 'table' => 'items'), null, true) ?>">Usuń</a>
                                <div id="ajx-pdata-<?php echo $item['itemId'] ?>d" class="ajax-post-data"><?php echo Zend_Json::encode(array('deleted' => 1)) ?></div>

 <!--                               <a href="<?php echo $this->url(array('module' => 'admin', 'action' => 'itemedit', 'id' => $item['itemId']), null, true) ?>">Edytuj</a>-->


                                <!--<a href="<?php echo $this->url(array('module' => 'admin', 'action' => 'itemadd',), null, true) ?>">Dodaj</a>-->
                                
                                <div id="ajx-pdata-<?php echo $item['itemId'] ?>" class="ajax-post-data"><?php echo Zend_Json::encode(array('status' => $item['status'] == Application_Model_Items::S_HOME ? Application_Model_Items::S_NEW : Application_Model_Items::S_HOME)) ?></div>

                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="8">
                        <?php
                        echo $this->paginationControl($this->paginator, 'Sliding', 'pg_nav01.phtml');
                        ?>
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>
<input type="hidden" value="" id="urlAdd" />
<script type="text/javascript">
    $(function(){
        $( ".tabs" ).tabs({
            activate: function( event, ui ) {
        
                if(!event.handleObj)
                    return;
                var tab = ui.newTab.children('a').attr('rel');
                $('.filterField[name=filterstatus]').val(tab);
                $('#urlAdd').val('/tab/'+(tab==0?1:0));
                $('.ajaxFilter').click();
            }
        });
        var tab = window.location.pathname.getParam('tab');
        $('#urlAdd').val((tab!=undefined?'/tab/'+tab:''));
        $( ".tabs" ).tabs( "option", "active",tab );
        
    });
</script>
